#include <EXTERN.h>
#include <perl.h>

int main(int argc, char** argv, char** env) {
   PerlInterpreter *my_perl;
   char *switches[] = {"", "-e", "0"};
   HV* hash;
   SV** value;

   my_perl = perl_alloc();
   perl_construct(my_perl);
   perl_parse(my_perl, NULL, 3, switches, (char**)NULL);
   perl_run(my_perl);

   /* create the hash */
   hash = newHV();

   /* store the 'test' value... */
   hv_store(hash, "test", 4, newSViv(42), 0);

   /*...and fetch it */
   value = hv_fetch(hash, "test", 4, 0);

   /* first check it is defined */
   if(NULL != value) {
      printf("hash{test}=%d\n", SvIV(*value));
   }

   perl_destruct(my_perl);
   perl_free(my_perl);
}
